package com.lj.demo.eduservice.controller;


import com.lj.demo.commonutils.R;
import com.lj.demo.eduservice.client.VodClient;
import com.lj.demo.eduservice.entity.EduVideo;
import com.lj.demo.eduservice.entity.VideoInfoForm;
import com.lj.demo.eduservice.service.EduVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author liujiang
 * @since 2020-12-03
 */
@RestController
@RequestMapping("/eduservice/eduVideo")
@CrossOrigin
//@Api(description = "小节管理")
public class EduVideoController {
    @Autowired
    private EduVideoService eduVideoService;



    @ApiOperation(value = "添加小节")
    @PostMapping("/addVideInfoForm")
    public R addVideo(@RequestBody VideoInfoForm videoInfoForm){
        eduVideoService.addVideInfoForm(videoInfoForm);
        return R.ok();
    }

    @ApiOperation(value = "修改小节")
    @PostMapping("/editVideInfoForm")
    public R editVideo(@RequestBody VideoInfoForm videoInfoForm){
        eduVideoService.editVideInfoForm(videoInfoForm);
        return R.ok();
    }

    @ApiOperation(value = "根据id查询小节")
    @GetMapping("/findVideoById/{id}")
    public R selectVideoById(
            @PathVariable String id){
        VideoInfoForm videoInfoForm = eduVideoService.findVideoById(id);
        return R.ok().data("items",videoInfoForm);
    }

    @ApiOperation(value = "根据id删除小节")
    @DeleteMapping("deleteVideoById/{id}")
    public R deleteVideoById(@PathVariable String id){
        boolean b = eduVideoService.removeViodeByid(id);
        if (b){ return R.ok();
        }return R.error();
    }



}

